<!--
 * @Author: wuzhen
 * @Date: 2019-12-04 17:56:54
 * @LastEditors  : wuzhen
 * @LastEditTime : 2020-01-11 10:39:52
 * @Description: 用户管理
 -->
<template>
  <Card style="width:100%" dis-hover>
    <p slot="title">
      <span class="primary">{{groupname}}</span>的成员
    </p>
    <p slot="extra">
      <router-link to="/groupManagement">
        <Icon type="ios-arrow-back" /> 返回
      </router-link>
    </p>
     <!-- 搜索表头/表头按钮 -->
    <search-table :search-props="searchProps"  @handle-click="handleClick" @handle-filter="handleFilter" />

    <wz-table ref="table" :search-api="searchApi" :columns="columns" :handle-btn="handleBtn">
      <template v-slot:action="slotProps">
        <Dropdown placement="bottom-start" @on-click="(e) => handleClick(e,slotProps.row)">
          <a href="javascript:void(0)">
            操作
            <Icon type="md-more" />
          </a>
          <DropdownMenu slot="list">
            <DropdownItem name="detail">查看用户</DropdownItem>
            <DropdownItem name="on">{{slotProps.row.status === 10?'帐户停用':'帐户启用'}}</DropdownItem>
            <DropdownItem name="offline" :disabled="slotProps.row.onlinestatus === 10">强制下线</DropdownItem>
            <DropdownItem name="offline">好友管理</DropdownItem>
            <DropdownItem name="offline">修改</DropdownItem>
          </DropdownMenu>
        </Dropdown>
      </template>
    </wz-table>
  </Card>
</template>
<script>
import index from "./mixins";
import { getGroupUser,removeUserFromGroup } from "@/request/api";
export default {
  mixins: [index],
  data() {
    return {
      groupname: this.$route.query.groupname || "",
      searchApi: getGroupUser,
      apiParams: {
        flipper: {
          offset: 0,
          limit: 15
        },
        bean:{
          groupid: this.$route.params.id
        }
        
      },
      type: "mobile",
      keyword: "",
      messageids: []
    };
  },
  mounted() {
    this.getData();
  },
  methods: {
    // 获取table数据
    getData() {
      this.$refs.table.getData(this.apiParams);
    },
   // 查询
    handleFilter(params) {
      this.apiParams["bean"].userid = params.userid;
      this.getData();
    },
    handleClick(type, row) {
      this.id = row.userid;
      switch (type) {
        default:
          break;
      }
    },
    // 删除
    onDelete(row) {
      this.$Modal.warning({
        title: "友情提示",
        content: "确定要移除该成员？",
        closable: true,
        onOk: async () => {
          const res = await removeUserFromGroup({
           userid:row.userid,
             groupid:row.groupid
          });
          if (res.code === 200) {
            this.$Message.success("操作成功");
            this.getData();
          }
        }
      });
    }
  }
};
</script>
